Skip to content

feat(cli): add aignostics-sdk slim CLI entry point [PYSDK-137]#658

Open
ari-nz wants to merge 1 commit into
feat/PYSDK-136/import-rewritefrom
feat/PYSDK-137/slim-cli
Open

feat(cli): add aignostics-sdk slim CLI entry point [PYSDK-137]#658
ari-nz wants to merge 1 commit into
feat/PYSDK-136/import-rewritefrom
feat/PYSDK-137/slim-cli

Conversation

@ari-nz
Copy link
Copy Markdown
Collaborator

@ari-nz ari-nz commented May 28, 2026

Release Train — PYSDK-133

Verify wiring on the integration branch first: #661 (draft, targets main)

Step PR Jira Phase Notes
1 #653 PYSDK-134 Workspace scaffolding Merge first — gates everything below
2a #656 PYSDK-135 Source migration After #653
2b #655 PYSDK-138 Dependency split After #653, parallel with 2a
2c #654 PYSDK-139 Tooling updates After #653, parallel with 2a
3 #657 PYSDK-136 Import rewrite After #656
4a #658 PYSDK-137 Slim CLI After #657
4b #659 PYSDK-141 Tests After #657, parallel with 4a
#651 PYSDK-140 CI/CD pipeline Independent — merge any time
#652 PYSDK-142 Docs & migration Independent — merge any time

Retargeting: each PR currently targets its predecessor branch. After the predecessor merges into feat/PYSDK-133/python-sdk-slim, retarget this PR to feat/PYSDK-133/python-sdk-slim before merging it.


This PR — Step 4a: Merge after #657 (import rewrite), parallel with #659. Retarget to feat/PYSDK-133/python-sdk-slim first.

Summary

  • Adds packages/aignostics-sdk/src/aignostics_sdk/cli.py — the entry point for the aignostics-sdk slim distribution CLI (wired via aignostics-sdk = "aignostics_sdk.cli:cli" in pyproject.toml)
  • Exposes only the platform sub-commands: user (login, logout, whoami) and sdk (run-metadata-schema, item-metadata-schema)
  • Deliberately skips prepare_cli() auto-discovery to prevent the heavy domain modules (application, wsi, dataset, bucket, qupath, system) from being pulled in via locate_implementations(typer.Typer) which deep-scans the aignostics package

aignostics-sdk --help output

Usage: aignostics-sdk [OPTIONS] COMMAND [ARGS]...

 Command Line Interface (CLI) of Aignostics SDK providing access to Aignostics
 Platform.

╭─ Options ──────────────────────────────────────────────────────────────────╮
│ --install-completion          Install completion for the current shell.    │
│ --show-completion             Show completion for the current shell.       │
│ --help                        Show this message and exit.                  │
╰────────────────────────────────────────────────────────────────────────────╯
╭─ Commands ─────────────────────────────────────────────────────────────────╮
│ user  User operations such as login, logout and whoami.                    │
│ sdk   Platform operations such as dumping the SDK metadata schema.         │
╰────────────────────────────────────────────────────────────────────────────╯

 🔬 Aignostics SDK v1.4.0 - built with love in Berlin 🐻 // Python v3.14.3

Included commands: user login, user logout, user whoami, sdk run-metadata-schema, sdk item-metadata-schema

Excluded commands: application, wsi, dataset, bucket, qupath, notebook, gui, system, launchpad, mcp

Why not prepare_cli()?

prepare_cli() calls locate_implementations(typer.Typer) which deep-scans the package named __project_name__ (hardcoded as "aignostics"). In the monorepo workspace — and in any installation where the full aignostics package is present — this would silently add all heavy domain CLIs, defeating the purpose of the slim distribution. The fix is to apply only the UX helpers (_add_epilog_recursively, _no_args_is_help_recursively) directly, without the auto-discovery step.

Test plan

  • uv run --package aignostics-sdk aignostics-sdk --help shows only user and sdk commands
  • uv run --package aignostics-sdk aignostics-sdk user --help shows login/logout/whoami
  • uv run --package aignostics-sdk aignostics-sdk sdk --help shows metadata-schema commands
  • make lint passes (ruff + pyright + mypy)
  • No heavy module commands (application, wsi, dataset, bucket, qupath, notebook, gui, system, launchpad) appear in help output

Creates packages/aignostics-sdk/src/aignostics_sdk/cli.py with a
trimmed Typer app exposing only the platform CLI commands (user, sdk).

Deliberately avoids calling prepare_cli() to prevent auto-discovery
of heavy domain modules (application, wsi, dataset, bucket, qupath,
system) via locate_implementations(typer.Typer). Instead, applies
epilog and no-args-is-help behaviour directly by calling the private
helpers _add_epilog_recursively and _no_args_is_help_recursively.
Copilot AI review requested due to automatic review settings May 28, 2026 11:32
@ari-nz ari-nz requested a review from a team as a code owner May 28, 2026 11:32
@ari-nz ari-nz added the skip:test:long_running Skip long-running tests (≥5min) label May 28, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a dedicated CLI entry point for the aignostics-sdk slim distribution, intentionally avoiding the prepare_cli() auto-discovery that would deep-scan the aignostics package and pull in heavy domain modules.

Changes:

  • Introduces aignostics_sdk/cli.py as the slim CLI entry point.
  • Registers only platform-level subcommands (user, sdk) on the root Typer app.
  • Applies existing CLI UX helpers (epilog + “no args shows help”) without running module auto-discovery.

Comment on lines +14 to +15
from aignostics_sdk.platform import cli_sdk, cli_user
from aignostics_sdk.utils import __python_version__, __version__

from aignostics_sdk.platform import cli_sdk, cli_user
from aignostics_sdk.utils import __python_version__, __version__
from aignostics_sdk.utils._cli import _add_epilog_recursively, _no_args_is_help_recursively
Comment on lines +20 to +22
cli = typer.Typer(
help="Command Line Interface (CLI) of Aignostics SDK providing access to Aignostics Platform.",
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip:test:long_running Skip long-running tests (≥5min)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants